#!/usr/bin/python
# -*- coding: utf-8 -*-


import os
import cherrypy

hostPort = 17138

class LogIn(object):
	def readFile(self,fn):
		fin = open(fn, 'r')
		r = fin.read()
		fin.close()
		return r

	def index(self):
		try:
			return self.readFile('html/index.html')
		except Exception, e:
			return ''
		
	def news(self):
		return self.readFile('html/news.html')

	def history(self):
		return self.readFile('html/history.html')
		
	def beer(self):
		return self.readFile('html/beer.html')

	def contacts(self):
		return self.readFile('html/contacts.html')

	def sitemap(self):
		return self.readFile('html/sitemap.html')


#	new function here
	index.exposed = True
	news.exposed = True
	history.exposed = True
	beer.exposed = True
	contacts.exposed = True
	sitemap.exposed = True


current_dir = os.path.dirname(os.path.abspath(__file__))

conf = 	{
			'/': {'tools.encode.on':True, 'tools.encode.encoding':'utf-8', 'tools.proxy.on':True},
			'/': {'tools.staticdir.on': True, 'tools.staticdir.dir': os.path.join(current_dir, '')},
			'/html': {'tools.staticdir.on': True, 'tools.staticdir.dir': os.path.join(current_dir, 'html'), 'tools.staticdir.content_types': {'css': 'text/css', 'manifest': 'text/cache-manifest'}},
			'/js': {'tools.staticdir.on': True, 'tools.staticdir.dir': os.path.join(current_dir, 'js')},
			 'global':	{ 'server.environment': 'production',
			'engine.autoreload_on': True,
			'engine.autoreload_frequency': 5,
			'server.socket_host': '0.0.0.0',
			'server.socket_port': hostPort}
		}


cherrypy.quickstart(LogIn(), '/', config=conf)

